<?php
/**
 * Created by PhpStorm.
 * userValidate: hms
 * Date: 2018/11/26
 * Time: 15:23
 */
namespace app\mini\validate;

use think\Validate;

class authValidate extends Validate
{

    protected $rule = [
        'username' =>  'require',
        'certificate' =>  'require|checkIdCard:thinkphp',
        'mobile_code'  =>  'require',
        'bank_mobile'=>'require',
    ];

    protected $message = [
        'username.require' => '真实姓名不能为空',
        'mobile_code.require' => '请输入验证码',
        'bank_mobile.require' => '手机号不能为空',
        'certificate.require' => '身份证号不能为空',
    ];

    protected function checkIdCard($value)
    {
        return preg_match('/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/', $value) ? true : '身份证号输入错误';
    }

}